package com.scsj.supermarket.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.orhanobut.logger.Logger;
import com.scsj.supermarket.R;
import com.scsj.supermarket.baseurl.BaseUrl;
import com.scsj.supermarket.bean.CatgroyItemBean;
import com.scsj.supermarket.bean.HomeClassifyBean;
import com.scsj.supermarket.utils.SkipUtils;

import java.util.List;

/**
 * 商品分类
 */

public class CatgroyItemAdapter extends BaseQuickAdapter<HomeClassifyBean.DataBean.AppGoodsClassPt2VoListBean,BaseViewHolder> {


    private Context context;
    public CatgroyItemAdapter(Context context,List data) {
        super(R.layout.item_catgroy_layout,data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, final HomeClassifyBean.DataBean.AppGoodsClassPt2VoListBean item) {
        helper.setText(R.id.textView, item.getGoodsClassPt2().getName());
//        helper.setImageResource(R.id.imageview, R.mipmap.zzz_clothing);
//        // TODO: 2018/6/26  图片加载暂时没做
//        Logger.d("图片URL=>"+item.getResourceInfoSmall().getUrlFrameCapture());
        ImageView imageView = helper.getView(R.id.imageview);
      //  Glide.with(context).load(item.getResourceInfoSmall().getUrlFrameCapture()).into(imageView);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SkipUtils.toSearchResultPage(context,item.getGoodsClassPt2().getName());
            }
        });
    }
}
